select * from AccountInfo
select * from BankCard
select * from CardExchange
select * from CardStateChange
select * from CardTransfer
go
--1）编写视图实现查询出所有银行卡账户信息，显示卡号，身份证，姓名，余额。

create view V_accountinfo(卡号,身份证号,姓名,余额)
as
select CardNo,AccountCode,RealName,CardMoney from AccountInfo ac
inner join BankCard ba on ac.AccountId=ba.AccountId
go
select * from V_accountinfo

--2）行转列常用做法: group by + sum(case when) /+count(case when)  数据分析+ over (paritition by, order by)
select year,
max(case month when 1 then amount else 0 end) m1,
max(case month when 2 then amount else 0 end) m2,
max(case month when 3 then amount else 0 end) m3,
max(case month when 4 then amount else 0 end) m4
from securities
group by year